f = open('111.txt', 'r', encoding='utf-8')
print(f.read())

with open('111.txt', 'r', encoding='utf-8') as file:
    text = file.read()
print(text)

f1 = open(r'C:\Users\Administrator\Desktop/111.txt', encoding='utf-8')
print(f1.read())

f2 =open('222.txt', 'w', encoding='utf-8')
f2.write('嘻嘻嘻嘻哈哈哈哈呵呵呵呵')
f2.close()

date = '哇塞任嘉伦哎'
with open('222.txt', 'w', encoding='utf-8') as f:
    f.write(date)


import pandas as pd

df = pd.read_excel(r'C:\Users\Administrator\Desktop\111.xlsx')
print(df)

# 写文件到excel文件
a1 = {'name': 'zhaowanying', 'age': 18}
a2 = {'name': 'zhaoyaru', 'age': 18}
a3 = {'name': 'wangziman', 'age': 18}
l = [a1, a2, a3]
print(l)
# 需要将列表变成DataFrame格式
df1 = pd.DataFrame(l)
print(df1)
df1.to_excel('222.xlsx', index=False)


from docx import Document

doc = Document('111.docx')
print(doc)
p = doc.paragraphs
print(p)
print(len(p))
for i in p:
    print(i.text)

# 处理word文档，需要下载python-docx
# 导入docx库中的Document模块
from docx import Document
# 打开docx文档，获取文档对象
doc = Document('2023年国务院政府工作报告.docx')
print(doc)
# 获取word段落，使用paragraphs，得到的是列表
p = doc.paragraphs
print(p)
print(len(p))
# 遍历列表，显示段落内容，使用text
for i in p:
    print(i.text)